<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function deepCopy(source) {
            if (typeof source !== 'object') {
                throw Error('不是对象')
                return
            }
            const target = source instanceof Array ? [] : {}
            for (let key in source) {
                target[key] = typeof source[key] === 'object' ? deepCopy(source[key]) : source[key]
            }

            return target
        }

        console.log(deepCopy(1))
    </script>
</body>

</html>